package com.xm.settlement.controller;

import com.xm.settlement.commons.base.BaseController;
import com.xm.settlement.commons.utils.PageInfo;
import com.xm.settlement.model.UserExpansion;
import com.xm.settlement.service.UserExpansionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2017/5/1.
 */
@Controller
@RequestMapping("/vipInfo")
public class VipInfoController extends BaseController {
    @Autowired
    private UserExpansionService expansionService;


    /**
     * 会员信息主页
     *
     * @return
     */

    @GetMapping(value = "/manager")
    public String Manager() {
        return "settlement/vipInfo/vipInfo";
    }


    /**
     * 会员信息管理
     * @param page
     * @param rows
     * @param sort
     * @param Ship
     * @return
     */

    @PostMapping("/dataGrid")
    @ResponseBody
    public Object dataGrid(Integer page, Integer rows, String sort, String Ship) {
        PageInfo pageInfo = new PageInfo (page, rows, sort, Ship);
        Map<String, Object> condition = new HashMap<String, Object>();
        pageInfo.setCondition(condition);
        expansionService.selectDataGrid(pageInfo);
        return pageInfo;
    }

/*
    *//**
     * 添加会员信息页
     *
     * @return
     *//*
    @RequestMapping("/addPage")
    public String addPage() {
        return "settlement/vipInfo/vipInfoAdd";
    }*/


 /*   *//**
     * 添加会员信息
     * @param
     * @return
     *//*
    @PostMapping("/add")
    @ResponseBody
    public Object add(UserExpansion userExpansion) {
        userExpansion.setLogin_name(getStaffName());
        expansionService.insert(userExpansion);
        return renderSuccess("添加成功！");
    }
*/

    /**
     * 编辑会员信息页
     *
     * @param model
     * @param id
     * @return
     */
    @GetMapping("/editPage")
    public String editPage(Model model, Long id) {
        UserExpansion userExpansion = expansionService.selectById(id);
        model.addAttribute("userExpansion", userExpansion);
        return "settlement/vipInfo/vipInfoEdit";
    }


    /**
     * 编辑会员信息
     *
     * @param
     * @return
     */
    @RequestMapping("/edit")
    @ResponseBody
    public Object edit(UserExpansion userExpansion) {
        expansionService.updateSelectiveById(userExpansion);
        return renderSuccess("编辑成功！");
    }


/*
    *//**
     * 删除会员信息
     *
     * @param id
     * @return
     *//*
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id) {
        expansionService.deleteById(id);
        return renderSuccess("删除成功！");
    }*/
}
